package com.cdie.myschool.mapper.TeacherTermReportMapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cdie.myschool.domain.entity.Calendar;
import com.cdie.myschool.domain.entity.Papers;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

/**
 * @program:my-school
 * @ClassName:PapersMapper
 * @Description:科研信息
 * @author:毛康源
 * @data:2022-10-09 13:22
 **/
@Mapper
public interface PapersMapper extends BaseMapper<Papers> {
    //查询科研信息表的时间戳
    @Select("select timestamp from papers where teacher_id=#{teacherId}")
    List<Papers> getTimestampListPapers(String teacherId);

    @Select("select semester_id from calendar where #{timestamp}>=begin_time and #{timestamp}<=end_time")
    Calendar getSemesterIdPapers(Date timestamp);

    @Select("select semester_id from calendar where #{timestamp}>=begin_time and #{timestamp}<=end_time")
    Integer getSeIdsPapers(Date timestamp);

    @Update("update papers set semester_id=#{semesterId} where teacher_id=#{teacherId} and timestamp=#{timestamp}")
    int updateSemeterIdPapers(@Param("semesterId") Integer semesterId, @Param("teacherId") String teacherId, @Param("timestamp") Date timestamp);


}
